﻿/*----------------------------------------------------------------
// Copyright (C) 2011 上海
// 版权所有。 
//
// 文件名：SubsidyPaymentInfo
// 文件功能描述：补贴发放业务逻辑层
//
// 
// 创建标识：2012-05-24 王冲
//
// 修改标识：
// 修改描述：
//
//
//----------------------------------------------------------------*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DAO.WaiGaoQiao;

namespace Model.WaiGaoQiao
{
    public class SubsidyPaymentInfo
    {
        /// <summary>
        /// 卡流水号
        /// </summary>
        public int CardNo
        {
            get;
            set;
        }
        /// <summary>
        /// 人员编号
        /// </summary>
        public string EmpNo
        {
            get;
            set;
        }
        /// <summary>
        /// 人员姓名
        /// </summary>
        public string PName
        {
            get;
            set;
        }
        /// <summary>
        /// 卡序列号
        /// </summary>
        public Int64 CardSerial
        {
            get;
            set;
        }
        /// <summary>
        /// 部门名称
        /// </summary>
        public string deptName
        {
            get;
            set;
        }
        /// <summary>
        /// 卡类型（人员类型）
        /// </summary>
        public string PersonTypeName
        {
            get;
            set;
        }
        /// <summary>
        /// 消费余额
        /// </summary>
        public decimal Balance
        {
            get;
            set;
        }
        /// <summary>
        /// 要增减款的卡流水号的集合
        /// </summary>
        public string CardNoAdd
        {
            get;
            set;
        }
        /// <summary>
        /// 增减类型编号
        /// </summary>
        public int DepositTypeID
        {
            get;
            set;
        }
        /// <summary>
        /// 增减类型名称
        /// </summary>
        public string DepositName
        {
            get;
            set;
        }
        /// <summary>
        /// 补贴金额
        /// </summary>
        public decimal Money
        {
            get;
            set;
        }
        /// <summary>
        /// 操作员号
        /// </summary>
        public string OperatorID
        {
            get;
            set;
        }
        /// <summary>
        /// 余额上限
        /// </summary>
        public decimal BalanceLimit
        {
            get;
            set;
        }

        private DataAccessSubsidyPayment dar;
        private int SubsidyPaymentcount;
        public int _SubsidyPaymentcount
        {
            get { return SubsidyPaymentcount; }
        }
        public SubsidyPaymentInfo(bool isgetcount)
        {
            dar = new DataAccessSubsidyPayment();
            if (isgetcount)
            {
                SubsidyPaymentcount = GetSubsidyPaymentCount();
            }
        }
        public SubsidyPaymentInfo()
        { }

        /// <summary>
        /// 已发所有已发卡且状态为正常的卡的补贴卡的数量
        /// </summary>
        /// <returns></returns>
        private int GetSubsidyPaymentCount()
        {
            return dar.GetSubsidyPaymentCount();
        }

        /// <summary>
        /// 已发所有已发卡且状态为正常的卡的补贴卡的数量
        /// </summary>
        /// <returns></returns>
        public int GetSubsidyPaymentCount(string where)
        {
            return dar.GetSubsidyPaymentCount(where);
        }

        /// <summary>
        /// 获取部门列表（用于绑定下拉框）
        /// </summary>
        /// <returns></returns>
        public DataSet GetdeptName()
        {
            return dar.GetdeptName();
        }

        /// <summary>
        /// 获取所有已发卡且状态为正常的卡的补贴卡的信息（分页）
        /// </summary>
        /// <param name="pagesize"></param>
        /// <param name="startindex"></param>
        /// <returns></returns>
        public IList<SubsidyPaymentInfo> SelSubsidyPaymentInfo(int pagesize, int startindex, string strquery)
        {
            IList<SubsidyPaymentInfo> funlist = new List<SubsidyPaymentInfo>();
            SubsidyPaymentInfo funinfo;
            DataSet ds = dar.SelSubsidyPaymentInfo(pagesize, startindex, strquery);
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                funinfo = new SubsidyPaymentInfo()
                {
                    CardNo = Convert.ToInt32(item["CardNo"]),
                    EmpNo = item["EmpNo"].ToString(),
                    PName = item["PName"].ToString(),
                    CardSerial = Convert.ToInt64(item["CardSerial"]),
                    deptName = item["deptName"].ToString(),
                    PersonTypeName = item["PersonTypeName"].ToString(),
                    Balance = (Convert.ToDecimal(item["Balance"])) / 100
                };
                funlist.Add(funinfo);
            }
            return funlist;
        }

        public IList<SubsidyPaymentInfo> SelLeftBox(string strquery)
        {
            IList<SubsidyPaymentInfo> funlist = new List<SubsidyPaymentInfo>();
            SubsidyPaymentInfo funinfo;
            DataSet ds = dar.SelLeftBox(strquery);
            foreach (DataRow item in ds.Tables[0].Rows)
            {
                funinfo = new SubsidyPaymentInfo()
                {
                    EmpNo = item["EmpNo"].ToString(),
                    PName = item["PName"].ToString()
                };
                funlist.Add(funinfo);
            }
            return funlist;
        }

        public int SaveSubgidyPayment(SubsidyPaymentInfo fun, string[] sempall)
        {
            object[] obj = new object[] { fun.BalanceLimit, fun.Money, fun.OperatorID };
            return dar.SaveSubgidyPayment(obj, sempall);
        }
    }
}
